Exchange Server Share

… Information sharing on Exchange Server …

PowerShell: Export Multivalued Properties

You would have seen that, when we try to export multivalued property to CSV file with Export-CSV command, it just copies Definition instead of all the values of that multivalued property.

Let’s take couple of examples…

Example 1: Export Blocked Recipients from the Recipient Filtering configuration.

When we export Blocked Recipients with below command, it exports Definition of the BlockedRecipients property instead of all the values because it is a multivalued property.

Get-RecipientFilterConfig | Select Name, BlockedREcipients | Export-CSV BlockedRecipient.csv

image

image

Resolution:

We need to join all the values of multivalued property with Join function before exporting it.

So our final command to export all the values of BlockedRecipients multivalued property is below.

Get-RecipientFilterConfig | Select Name, @{Name=’BlockedRecipients’;Expression={[string]::join(";", ($_.BlockedREcipients))}} | Export-CSV BlockedRecipient.csv 

image

image 

Example 2: Export all the email addresses of a user.

When we export the EmailAddresses property with below command, it just exports Definition.

Get-Mailbox "Tank, Amit M" | Select Name, EmailAddresses | Export-CSV EmailAddress.csv

image

So we need to join all the email addresses before exporting to CSV file and our final command is below.

Get-Mailbox "Tank, Amit M" | Select Name, @{Name=’EmailAddresses’;Expression={[string]::join(";", ($_.EmailAddresses))}} | Export-CSV EmailAddress.csv

image

This would be even more helpful when we want to export a multivalued property for bulk of users, like when we export email addresses of all the users of an Exchange environment with below command.

Get-Mailbox | Select Name, @{Name=’EmailAddresses’;Expression={[string]::join(";", ($_.EmailAddresses))}} | Export-CSV EmailAddress.csv

Written by Amit Tank

December 10, 2008 at 3:31 pm